<?php
//=========================
//Vuong Van Binh
//Wanbin@vietnambiz.com
//========================
//CHECK PERMISSION

if(check_permission($_SESSION['adlogin']["id"],$module)==false) {

    include ADMIN_INCLUDE_DIR."/header.php";

    echo "<div style='float:left; height:20px; display:inline; margin-left: 280px; margin-top: 10px; font-size:12px; border:3px orange solid; padding:10px;'><font color=red><b>:)) You have not permission to control this modules. Please Contact to administrator to know detail addly...</b></font></div>";
    die();
}
//===============================
// center

echo "<div class='container'>";


switch($option) {
    case "add": {
            $add_class="class='active'";
            include "member_add.php";
            break;
    }case "member-preview": {
            include "member_preview.php";
            break;
    }case "send-email" 	: {
            $send_email_class="class='active'";
            include "member_send_email.php";
            break;
    }case "edit"    : {
            $edit_class="class='active'";
            include "member_edit.php";
            break;
    }case "personal": {
            $per_class="class='active'";
            include "member_personal.php";
            break;
    }case "company" : {
            $com_class="class='active'";
            include "member_company.php";
            break;
   }case "send-message" : {
            $com_class="class='active'";
            include "member_send_message.php";
            break;
	}case "delete-member" : {
			$data = array();
			$arrMemUsername = explode(',',$_REQUEST['members']);
            $data["is_delete"] 	= 1;
			foreach($arrMemUsername as $k=>$v){
				$rsMemId = $db->query_first("SELECT mem_id FROM members WHERE username='$v'");
				$mem_id = $rsMemId['mem_id'];
				if(intval($mem_id)>0){
					$db->query_first("DELETE FROM members WHERE mem_id=$mem_id");
					$db->query_first("DELETE FROM members_info WHERE mem_id=$mem_id");
					$db->query_first("DELETE FROM favourite_property WHERE uid=$mem_id");
					$db->query_first("DELETE FROM member_message WHERE from_id=$mem_id OR to_id=$mem_id");
					$rsPropertyId = $db->query_first("SELECT id FROM property WHERE member_id=$mem_id");
					$propertyId = $rsPropertyId['id'];
					$db->query_first("DELETE FROM property WHERE member_id=$mem_id");
					if(intval($propertyId)>0){
						$db->query_first("DELETE FROM property_image WHERE property_id=$propertyId");
					}
				}
			}
			header("Location: ".get_string_url(array('option','members')));
            break;
    }case "feedback": {
            $feed_class="class='active'";
            include "member_message.php";
            break;

    }default       : {
            $per_class="class='active'";
            include "member_personal.php";
            break;
        }
}


//===============================            
echo "</div>";

?>